#include "Container.h"


Container::Container(void) : isDestroyed(false)
{
}

Container::~Container(void)
{
	destroy();
}

void Container::initSystem()
{
	QLOG_INFO() << "initializing system.";
}
void Container::initLogSystem(const QString& path, QsLogging::Level logLevel)
{
	QsLogging::Logger& logger = QsLogging::Logger::instance();
	logger.setLoggingLevel(logLevel);
	
	QsLogging::DestinationPtr fileDestination = QsLogging::DestinationFactory::MakeFileDestination(path,1024 * 1024 * 10,10);
	QsLogging::DestinationPtr consoleDestination(QsLogging::DestinationFactory::MakeConsoleDestination() );
	logger.addDestination(consoleDestination);
	logger.addDestination(fileDestination);
}
void Container::initCms()
{
	/*log->info("initializing cms lib and factory manager.");
	activemq::library::ActiveMQCPP::initializeLibrary();
	connectionCfg = new ConnectionConfig();
	factoryManager = new  FactoryManager (connectionCfg);*/
}
void Container::destroy()
{
	/*if(isDestroyed)
	{
		return;
	}
	isDestroyed = true;
	try
	{
		
		if(factoryManager != NULL)
		{
			try{delete factoryManager;}
			catch(...){}
			factoryManager = NULL;
		}

		if(connectionCfg != NULL)
		{
			try{delete connectionCfg;}catch(...){}
			connectionCfg = NULL;
		}
		activemq::library::ActiveMQCPP::shutdownLibrary();
		google::protobuf::ShutdownProtobufLibrary();
		log->info("destroyed Container.");
		Log4Qt::LogManager::shutdown();
	}
	catch(...)
	{
	}*/
}
